{% extends "layouts/application.html" %}
{% block content %}
<script type="text/javascript">
 $(document).ready(function() {
 	$("#img_upload").hide();
     var options = {
     	type:'post',
       	beforeSubmit:  showRequest,  // pre-submit callback
       	success:       showResponse  // post-submit callback
   	 };
     $('#upload_form').ajaxForm(options);
	function showRequest(formData, jqForm, options) {
		var title = $('input[@name=name]').fieldValue();
		var about = $('textarea[@name=about]').fieldValue();
		var file = $('input[@name=filepath]').fieldValue();
		var image = $('input[@name=filepic]').fieldValue();
		if(!title[0]){
			alert("文件标题不能为空！");
			return false
		}
		if(!about[0]){
			alert("文件说明不能为空！");
			return false
		}
		if(!file[0]){
			alert("上传附件不能为空！");
			return false
		}
		if(image[0]){
			var type = image[0].substring(image[0].indexOf('.'),image[0].length)
			if(type!=".jpg"&&type!=".jpeg"&&type!=".gif"&&type!=".bmp"&&type!=".png"){
				alert("对不起,您上传的图片格式不正确");
				return false
			}
		}
		$("#img_upload").show();
	    return true;
	}
	function showResponse(responseText, statusText)  {
		if(statusText="success"){
			$("#img_upload").hide();
			alert("文件上传完成");
			location.reload();
		}else{
			$("#img_upload").hide();
			alert("文件上传失败");
		}
	}
 });

</script>
<style type="text/css">
  ul{margin:0px;padding:0px;float:left;list-style:none;}
  li{margin-left:10px;padding:0px;color:red;}
</style>
<div align="center">
  <DIV class=boxright>
    <DIV class=bltop2>
      <div align="left">&nbsp;&nbsp;&nbsp;
        <strong>
          当前位置：&nbsp;&nbsp;
          <a href="{{obj.get_top_url}}">资料库</a>
          <img src="/site_media/images/zd_arrow.gif">&nbsp;&nbsp;
          <a href="/{%site_root%}/resource/file_midif/">文件上传</a>
        </strong>
      </div>
    </DIV>
    <DIV class=c_box>
      <DIV class="rep_left">
        <div class="bltop2">
        	<span class="s_left">上传文件</span>
          	<img id="img_upload" src="/site_media/images/uploading.gif" >
        </div>
        <form action="" id="upload_form" enctype="multipart/form-data" method="post">
        <div id="upfile_div">
          <TABLE id=tblSearch  cellSpacing=0 cellPadding=4  width="100%" border=0>
            <TBODY>
              <TR>
                <TD class=rep_li_c2 width="10%" >前缀一</TD>
                <TD class=rep_li_c2 width="10%" ALIGN="left">
                  {{form.prefix_one}}{{form.prefix_one.errors}}
                </TD>
                <TD class=rep_li_c2 width="10%">前缀二</TD>
                <TD class=rep_li_c2 width="10%" ALIGN="left">
                  {{form.prefix_two}}{{form.prefix_two.errors}}
                </TD>
                <TD class=rep_li_c2 width="10%">前缀三</TD>
                <TD class=rep_li_c2 width="18%" ALIGN="left">
                  {{form.prefix_three}}{{form.prefix_three.errors}}
                </TD>
              </TR>
              <tr>
                <TD class=rep_li_c2 width="18%">所属分类</TD>
                <TD class=rep_li_c2  COLSPAN="5" ALIGN="left">
				  {{form.cata}}{{form.cata.errors}}
                </TD>
              </tr>
              <TR>
                <TD class=rep_li_c2 width="18%">文件标题</TD>
                <TD class=rep_li_c2  COLSPAN="5" ALIGN="left">
                  {{form.name}}{{form.name.errors}}
                </TD>
              </TR>
              <TR>
                <TD class=rep_li_c2 width="18%">文件描述</TD>
                <TD class=rep_li_c2  COLSPAN="5" ALIGN="left">
                  {{form.about}}{{form.about.errors}}
                </TD>
              </TR>
              <TR>
                <TD class=rep_li_c2 width="18%">选择文件</TD>
                <TD class=rep_li_c2  COLSPAN="5" ALIGN="left">
                  {{form.filepath}}{{form.filepath.errors}}
                </TD>
              </TR>
              <tr>
                <TD class=rep_li_c2 width="18%">选择图片</TD>
                <TD class=rep_li_c2  COLSPAN="5" ALIGN="left">
                  {{form.filepic}}{{form.filepic.errors}}
                </TD>
              </tr>
              <TR>
                <TD class=rep_li_c2 colSpan=6>
                  <INPUT onMouseOver="this.className='submit2'" onMouseOut="this.className='submit'" class=submit id="" type=submit value=上传 name="">
                  <INPUT onMouseOver="this.className='reset2'" onMouseOut="this.className='reset'" id="reset_load" class="reset"  type="reset" value=取消>
                </TD>
              </TR>
            </TBODY>
          </TABLE>
        </div>
        </form>

      </DIV>
    </DIV>
	</DIV>
  </DIV>
  <div>
  </div>
</div>
{% endblock %}
